package com.huiyuanai.film.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huiyuanai.film.entity.Movie;
import com.huiyuanai.film.mapper.MovieMapper;
import com.huiyuanai.film.query.MovieQuery;
import com.huiyuanai.film.service.MovieService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 灰原哀
 * @since 2022-05-27
 */
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) //事务查询   @Transactional(propagation = Propagation.REQUIRED, readOnly = false)修改
public class MovieServiceImpl extends ServiceImpl<MovieMapper, Movie> implements MovieService {

    @Autowired
    MovieMapper movieMapper;

    @Override
    public PageInfo<Movie> moviesPage(MovieQuery movieQuery) {
        PageHelper.startPage(movieQuery.getCurrentPage(), movieQuery.getPageSize());
        Page<Movie> movies = (Page<Movie>) movieMapper.moviesPage(movieQuery);
        return movies.toPageInfo();
    }
}
